<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2><fmt:message key = "emploeeListForm.title"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<p>
  <a href = "adminui?_action=employeeForm"><fmt:message key = "Command.add"/></a>
</p>

<p>
<a href="adminui?_action=employessList&type=all">
<fmt:message key="Command.all"/>
</a>

<a href="adminui?_action=employessList&type=active">
<fmt:message key="Command.active"/>
</a>

<a href="adminui?_action=employessList&type=inactive">
<fmt:message key="Command.inactive"/>
</a>
</p>

<table width="100%" cellpadding="10" cellspacing="10">
      <thead>      
         <tr style="border-bottom: 1px #f1f1f1 solid;">            
           <th><a class="head" href="adminui?_action=employessList&orderBy=N&order=${order}&type=${type}">#</a></th> 
           <th><a class="head" href="adminui?_action=employessList&orderBy=name&order=${order}&type=${type}"><fmt:message key = "employee.lastName"/></a></th>                        
           <th><a class="head" href="adminui?_action=employessList&orderBy=group&order=${order}&type=${type}"><fmt:message key = "employee.group"/></a></th>
           <th><a class="head" href="adminui?_action=employessList&orderBy=type&order=${order}&type=${type}"><fmt:message key = "employee.type"/></a></th>
           <th><fmt:message key = "employee.operations"/></th>
         </tr>
      </thead>

      <tbody>                
           <c:forEach var = "employee" items = "${employessList}">
            <tr style="border-bottom: 1px #f1f1f1 solid;">               
               <td><c:out value = "${employee.id}"/></td>               
               <td><c:out value = "${employee.formName}"/></td>               
               <td><c:out value = "${employee.group.name}"/></td>
               <td><c:out value = "${employee.type.name}"/></td>
               <td>
                      <c:choose>
                         <c:when test="${employee.status == 'active'}">                     
                            <a href = "adminui?_action=setEmployeeStatus&status=delete&orderBy=${orderBy}&order=${order}&type=${type}&employee_id=${employee.id}">
                              <fmt:message key = "employee.operations.remove"/>
                            </a>                      
                          </c:when>
                          <c:otherwise>
                            <a href = "adminui?_action=setEmployeeStatus&status=restore&orderBy=${orderBy}&order=${order}&type=${type}&employee_id=${employee.id}">
                              <fmt:message key = "employee.operations.restore"/>
                            </a>
                          </c:otherwise>     
                      </c:choose>  
                        <a href = "adminui?_action=employeeForm&employee_id=${employee.id}">
                           <fmt:message key = "employee.operations.edit"/>
                        </a>

                        <a href = "adminui?_action=subordinateForm&employee_id=${employee.id}">
                           <fmt:message key = "employee.operations.subordinate"/>
                        </a>
               </td>
            </tr>
         </c:forEach>
      
      <c:if test="${fn:length(employessList) == 0}">
        <tr><td colspan = "5" align="center"><fmt:message key="emptyList"/></td></tr>
      </c:if>
  </tbody>
</table>

<p>
<a href = "adminui?_action=employeeForm">
  <fmt:message key = "Command.add"/>
</a>
</p>